home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Unix / satan-1.1.1 / bin / yp-chk.satan < prev    next >
Text File  |  1996-04-24  |  1KB  |  55 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # Query the NIS server.
  4. #
  5.  
  6. $running_under_satan = 1;
  7. require 'config/satan.cf';
  8. require 'config/paths.pl';
  9. require 'perl/misc.pl';
  10. require 'perl/hostname.pl';
  11. require 'perl/getfqdn.pl';
  12. require 'perllib/getopts.pl';
  13.  
  14. $usage="Usage: $0 [-t timeout -u -v] domain target\n";
  15. $opt_u = $untrusted_host;
  16. &Getopts("t:uv") || die $usage;
  17. $timeout = $short_timeout;
  18.  
  19. ($#ARGV == 1) || die $usage;
  20.  
  21. $domain = $ARGV[0];
  22. $target = $ARGV[1];
  23. $flags = "-v" if defined($opt_v);
  24. $timeout = $opt_t if defined($opt_t);
  25. $untrusted_host = $opt_u;
  26.  
  27. $flags = "$flags -t $timeout";
  28.  
  29. $service = &basename($0, ".satan");
  30. $severity = "x";
  31. $status = "a";
  32. $service_output = "";
  33.  
  34. $| = 1;
  35.  
  36. $command = "$YP_CHK $flags $domain passwd.byname $target";
  37.  
  38. print "$command\n" if $opt_v;
  39.  
  40. open(YP, "$command |") || die "$0: cannot run yp-chk";
  41. while(<YP>) {
  42.     if (defined($opt_v)) {
  43.         print;
  44.     }
  45.     if ($untrusted_host && /:.*:.*:.*:.*:.*:/) {
  46.         $trusted = "ANY\@ANY";
  47.         $severity = "us";
  48.         $trustee = "user\@$target";
  49.         $service_output = "NIS password file access";
  50.         $text = $service_output;
  51.         &satan_print();
  52.     }
  53.     # Other NIS problems later.
  54. }
  55.